home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13937 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  50 lines

  1. Path: cpsc.ucalgary.ca!davidt
  2. From: davidt@cpsc.ucalgary.ca (David Taylor)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: clearing the screen, in Linux
  5. Date: 27 Mar 1996 23:20:12 GMT
  6. Organization: University of Calgary CPSC
  7. Message-ID: <4jcifc$bu3@linux.cpsc.ucalgary.ca>
  8. References: <31564CDA.DB1@ljusdal.se> <4j5k9r$as1@netnews.upenn.edu> <4j7qa2$5a8@crash.microserve.net>
  9. NNTP-Posting-Host: fsj.cpsc.ucalgary.ca
  10.  
  11. In article <4j7qa2$5a8@crash.microserve.net>,  <avenger@zola.trend1.com> wrote:
  12. >In <4j5k9r$as1@netnews.upenn.edu>, son@red.seas.upenn.edu (Sonny) writes:
  13. >>use the system function in 
  14. >>#include<stdlib.h>
  15. >>
  16. >>system("clear");
  17. >>
  18. >
  19. >cout << "\027]2J";
  20. >
  21. >I think that should probably work. It will be faster as well.
  22.  
  23. The "right" way to do this is with termcap or curses.  That way it
  24. will work on any terminal.
  25.  
  26. The termcap way is:
  27.  
  28.     char tbuffer[2048];
  29.     char clearstr[20];
  30.     char *area = clearstr;
  31.  
  32.     if (tgetent (tbuffer, getenv ("TERM")) < 0) {
  33.         fprintf (stderr, "No termcap entry!\n");
  34.         exit (1);
  35.     }
  36.  
  37.     if (!tgetstr ("cl", &area))
  38.         strcpy (clearstr, "");
  39.  
  40.  
  41. Now each time you print clearstr, the screen will clear.  You might
  42. also need to link in -ltermcap.
  43.  
  44. Using termcap and curses is cover in more detail in the Linux
  45. Programmer's Guide (freely available at http://sunsite.unc.edu/mdw).
  46.  
  47. -- 
  48. Andrew Taylor     |email: davidt@cpsc.ucalgary.ca
  49.                   |www:   http://www.cpsc.ucalgary.ca/~davidt
  50.